package com.Servlet;

import com.Service.Impl.Okayapi_goodsServiceImpl;
import com.Service.Okayapi_goodsService;
import com.entity.Okayapi_goods;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * @Author: 冷俊杰
 * @Description: 商品界面展示
 * @DateTime: 2022/6/17 10:07
 **/
@WebServlet(name = "/GoodsServlet", value = "/GoodsServlet")
public class GoodsServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        Okayapi_goodsService service = new Okayapi_goodsServiceImpl();
        List<Okayapi_goods> goods = service.GOODS_LIST();
        System.out.println(goods);
        request.setAttribute("goods", goods);
        request.getRequestDispatcher("./products.jsp").forward(request, response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doPost(request, response);
    }
}